<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=latin1">
        <link rel="stylesheet" type="text/css" href="../padrao.css" />
        <link rel="stylesheet" href="../jQuery/lista.css" type="text/css" media="all" />
        <script type="text/javascript" src="../jQuery/jquery-1.2.1.pack.js"></script>
        <script type="text/javascript" src="../jQuery/busca.js"></script>
        <script type="text/javascript" src="../sorttable.js"></script>

        <title> Pesquisa de entradas </title>

        <?php
        include '../infobox.php';
        include '../verifica_usuario.php';
        include '../functions.php';
        include '../functions_office.php';
        include '../menu.php';
        ?>

    </head>
    <body>
        <div class="conteudo">
            <p class="titulopesquisa" align='center'> ENTRADAS </p>
            <?php
            $orderby = $_GET[orderby];
            if($orderby == ""){
                $orderby = "identrada";
            }
            include("mysqlconfig.inc");
            $query = "select * from ENTRADAS
                      ORDER BY $orderby DESC; ";


            $res = mysql_query($query);
            $num_reg = mysql_num_rows($res);
            echo "<table> ";
//titulos das colunas
            echo "<tr class='titulo'>";
            echo "<td> <a href='?orderby=identrada'>ID Entrada </a> </td>";
            echo "<td> <a href='?orderby=ATERROS_nome'> Aterro </a> </td>";
            echo "<td> <a href='?orderby=EMPRESAS_nome'>Empresa </a> </td>";
            echo "<td> <a href='?orderby=EMPRESAS_cpf_cnpj'>CPF/CNPJ </a> </td>";
            echo "<td> <a href='?orderby=CAMINHOES_placa'>Placa  </a> </td>";
            echo "<td> <a href='?orderby=tipo'>Tipo </td>";
            echo "<td> <a href='?orderby=FUNCIONARIOS_login'>Usuario  </a> </td>";
            echo "<td> <a href='?orderby=data'>Data  </a> </td>";
            echo "<td> <a href='?orderby=hora'>Hora  </a> </td>";
            echo "<td> <a href='?orderby=carta_ind'>Carta Emitida?  </a> </td>";
            echo "<td> <a href='?orderby=carta_num'>Carta Numero  </a> </td>";
            echo "<td> <a href='?orderby=valor'>Creditos consumidos  </a> </td>";
            echo "<td> <a href='?orderby=pgto_vip'>Creditos vip?  </a> </td>";
            echo "<td> <a href='?orderby=prestador'>Prestador  </a> </td>";
            echo "<td> <a href='?orderby=prestador_cnpj'>CNPJ Prestador  </a> </td>";
            echo "<td> <a href='?orderby=OBRAS_obras_id'>Obra ID  </a> </td>";
            echo "<td> <a href='?orderby=OBRAS_obras_nome'>Obra </a> </td>";
            echo "</tr>";

            for ($i = 0; $i < $num_reg; $i++) {
                $mostra = mysql_fetch_array($res);
                if ($i % 2 == 1) {
                    $tipolinha = "tipo1";
                } else {
                    $tipolinha = "tipo2";
                }
                echo "<tr class='$tipolinha'>";
                echo "<td> $mostra[identrada] </td>";
                echo "<td> $mostra[ATERROS_nome] </td>";
                echo "<td> $mostra[EMPRESAS_nome] </td>";
                echo "<td> $mostra[EMPRESAS_cpf_cnpj] </td>";
                echo "<td> $mostra[CAMINHOES_placa] </td>";
                echo "<td> $mostra[tipo] </td>";
                echo "<td> $mostra[FUNCIONARIOS_login] </td>";
                echo "<td> $mostra[data] </td>";
                echo "<td> $mostra[hora] </td>";
                echo "<td> $mostra[carta_ind] </td>";
                echo "<td> $mostra[carta_num] </td>";
                echo "<td> $mostra[valor] </td>";
                echo "<td> $mostra[pgto_vip] </td>";
                echo "<td> $mostra[prestador] </td>";
                echo "<td> $mostra[prestador_cpf_cnpj] </td>";
                echo "<td> $mostra[OBRAS_obras_id] </td>";
                echo "<td> $mostra[OBRAS_obras_nome] </td>";


                echo "</tr>";
            }
            echo "</table>";
//informa a quantidade de registros encontrados
            echo "$num_reg Entradas cadastradas <br>";
//encerra a conexão
            mysql_close($con);
            ?>
        </div>
    </body>
</html>